<?php
class Exotic extends BZ_Controller
{
    public function _init()
    {
        $this->load->model('tourism_goods_exotic_model', 'tourism_goods_exotic');
        $this->load->model('tourism_goods_base_model', 'tourism_goods_base');
    }

    public function index($region_id)
    {
        $result = $this->tourism_goods_exotic->findByRegionId($region_id);
        if ($result->num_rows() <= 0) {
            $this->alertError('该城市不存在');
        }
        $this->data['exotic'] = $result->row();
        $this->data['total'] = $this->tourism_goods_base->regionProductTotal($region_id);
        $this->data['tourism_goods'] = $this->tourism_goods_base->findByRegionProduct($region_id, 10, 0);
        $this->load->view('tourism/exotic/index', $this->data);
    }
    
    public function ajaxExotic()
    {
        $region_id = $this->input->post('id');
        $count = $this->input->post('count');
        $start = $this->input->post('start') + 1;
        $num   = ($start-1)*$count;
        $data['total'] = $this->tourism_goods_base->regionProductTotal($region_id);
        $data['tourism_goods'] = $this->tourism_goods_base->findByRegionProduct($region_id, $count,$num);
        echo json_encode(
            array(
                'html' => $this->load->view('tourism/exotic/ajax', $data, true)
            )
        );
        exit;
    }
}